package upload.api;

import java.io.*;
import java.util.Objects;
import java.util.Properties;

public class ConfigUtil {

    private static Properties properties;
    private static ConfigUtil configUtil = new ConfigUtil();

    static {
        InputStream inputStream = null;
        try {
            inputStream = ConfigUtil.class.getClassLoader().getResourceAsStream("config.properties");
            properties = new Properties();
            properties.load(new InputStreamReader(Objects.requireNonNull(inputStream), "UTF-8"));
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    private ConfigUtil() {

    }

    public static ConfigUtil getInstance() {
        return configUtil;
    }

    public String get(String key) {
        return properties.getProperty(key);
    };

}
